﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace GSdk.Shared
{
    public static class StringBuilderExtensionMethods
    {
        public static StringBuilder FromEnumerable(this StringBuilder builder, IEnumerable enumerable, Expression<Func<object, string>> expr = null)
        {
            foreach (var obj in enumerable)
                if (expr == null)
                    builder.AppendLine(obj.ToString());
                else
                    builder.AppendLine(expr.Compile().Invoke(obj));

            return builder;
        }
    }
}
